//版权说明：修正按钮、文本位置，版本号：3.0，生成日期：2021-12-26，作者：房晓童，内容：入侵检测器类
// 功能：入侵检测适配器各成员变量与函数，与其它文件的关系：继承自ArrayAdapter.java
package com.example.safehome;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

//入侵适配器类
public class BreakInAdapter extends ArrayAdapter<BreakInWarningRecord> {
    private int resourceId;

    public BreakInAdapter(Context context, int textViewResourceId, List<BreakInWarningRecord> bojects) {
        super(context, textViewResourceId, bojects);
        resourceId = textViewResourceId;
    }

    @Override
    public View getView(int position, View converView, ViewGroup parent) {

        //控件初始化
        BreakInWarningRecord record = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId, parent, false);
        TextView id = (TextView) view.findViewById(R.id.tv_id);
        TextView BreakInTime = (TextView) view.findViewById(R.id.tv_BreakInTime);
        TextView BreakInPlace = (TextView) view.findViewById(R.id.tv_BreakInPlace);
        TextView IsCallPolice = (TextView) view.findViewById(R.id.tv_IsCallPolice);
        TextView Detail = (TextView) view.findViewById(R.id.tv_Detail);

        //设置适配器相关内容
        id.setText(Integer.toString(record.getId()));
        BreakInTime.setText(record.getBreakInTime().toString());
        BreakInPlace.setText(record.getBreakInPlace());
        if (record.getIsCallPolice())
            IsCallPolice.setText("是");
        else
            IsCallPolice.setText("否");
        Detail.setText(record.getDetail());
        return view;
    }
}
